#!/usr/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License").  You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#ident	"%Z%%M%	%I%	%E% SMI"	/* from SVR4 bnu:Teardown 1.5 */

export IFS PATH
IFS=" 	
"
PATH="/usr/bin"

#
#	This shell tries to convert uucp from the QFT format back to the
#	the regular HoneyDanBer format and removes all sub directories
#	that created while running the QFT version of uucp.
#

echo "Converting uucp from QFT Format back to HoneyDanBer format\n"

SPOOL=/var/spool/uucp
#	chdir to remote spool directory
cd $SPOOL
if [ `pwd` != "$SPOOL" ]
then
	echo "CAN'T cd to $SPOOL"
	echo "$0 failed."
	exit 0
fi
for d in */?
do
#	chdir to grade directories of the remote
	cd $d
	if [ "$?" = 0 ]
	then
#	   move everything to parent (machine) directory
	   find . -print | cpio -pdvm ..
	   if [ "$?" = 0 ]
	   then
#		now remove everything in this directory
		rm -rf *
	   fi
	   cd $SPOOL
#	   if grade directory is now empty, remove it.
	   rmdir $d
	fi
done >/dev/null 2>&1
